package com.feifan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.feifan.pojo.UserDTO;

import java.sql.SQLException;

/**
 * @author Donald
 * @create 2019-03-19 23:28
 */
public interface UserMapper extends BaseMapper<UserDTO> {
    /**
     * 查找用户id的权限和角色
     * @param id
     * @return
     * @throws SQLException
     */
    UserDTO findAllRolesByUserId(Long id) throws SQLException;

    /**
     * 通过用户名获取权限
     * @param username
     * @return
     */
    UserDTO findRoleAndPremiss(String username);

    /**
     * 通过用户id 查找用户信息
     * @param id
     * @return
     * @throws SQLException
     */
    UserDTO findUserInfoById(Long id) throws  SQLException;

    UserDTO findUserInfoByUsernmae( String username);
    /**
     * 更新用户基本信息
     * @param userDTO
     * @return
     */
    int updateUserBaseInfoInt(UserDTO userDTO);

    /**
     * 新增用户
     * @param userDTO
     * @return
     * @throws SQLException
     */
    int insertUser(UserDTO userDTO) throws  SQLException;

    /**
     * 赋予默认角色
     * @param userId
     * @return
     */
    int insertRole(Long userId);

    /**
     * 查询用户名可用性
     * @param username
     * @return
     */
    int judgeUsernameIsOK(String username);

    /**
     * 查询邮箱可用性
     * @param email
     * @return
     */
    int judgeEmailIsOK(String email);
}
